"""
请大家编程，构造一个 three_gcd 和 three_lcm 函数，
    该函数完成三个数的最大公因数和最小公倍数的求解。
    例子：
        input:2,7,6
        output:gcd:1 lcm:42
"""


def greatest_common_divisor(x, y):
    a = max(x, y)
    b = min(x, y)
    if b == 0:
        return a
    return greatest_common_divisor(b, a % b)


def least_common_multiple(x, y):
    return x * y // greatest_common_divisor(x, y)


def three_gcd(a, b, c):
    x = greatest_common_divisor(a, b)
    return greatest_common_divisor(x, c)


def three_lcm(a, b, c):
    x = least_common_multiple(a, b)
    return least_common_multiple(x, c)


print(three_gcd(2, 7, 6))
print(three_lcm(2, 7, 6))
